package com.starbugs.wehcat.aop.aop2;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

// 切面类
@Aspect
public class MyAspect {

  @Around("this(com.starbugs.wehcat.aop.aop2.Apple)")
  public Object around(ProceedingJoinPoint pjp) throws Throwable {
    System.out.println("this is before around advice");
    Object result = pjp.proceed();
    System.out.println("this is after around advice");
    return result;
  }

  //@Before("execution(* com.starbugs.wehcat.aop.aop2.Apple.eat(..))")
  public void before1(){
    System.out.println("this is before");
  }

  // @After("execution(* com.starbugs.wehcat.aop.aop2.Apple.eat())")
  public void after1(){
    System.out.println("this is after1");
  }
}